from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time

testCase = "DBshop011_添加商品"

# 打开后台网站
firefox=openBrowser(urlAdmin)
# 登录账号
DBshopLoginAdmin(firefox)
# 点击商品管理 管理商品
DBshopEnterMenu2(firefox,"商品管理","管理商品")
# 点击添加商品
firefox.find_element_by_xpath('//a[@href="/dbshop/admin/goods/goods/add"]').click()
# 商品名称填写“苹果XR”,本店价格“7999”，商品类型“虚拟商品”
firefox.find_element_by_id("goods_name").send_keys("苹果XP")
firefox.find_element_by_id("goods_shop_price").send_keys("7999")
firefox.find_element_by_id("goods_type").click()
firefox.find_element_by_xpath('//option[@value="2"]').click()
# 点击保存商品按钮
firefox.find_element_by_xpath("/html/body/div[2]/div/div[2]/div/form/div/div[1]/div[2]/button").click()
#断言
try:
    firefox.find_elements_by_xpath("//td[@contains(text(),'7999')]").is_displayed() #is_displayed()函数判断元素是否显示
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()
